//
//  ToolBar.m
//  兼职页面
//
//  Created by kuiyuan liang on 2021/5/23.
//

#import "ToolBar.h"
#import "CommonUtil.h"

@interface ToolBar()

@property (strong, nonatomic) UIView * lineView1;
@property (strong, nonatomic) UIView * lineView2;
@property (strong, nonatomic) UIView * lineView3;

@end


@implementation ToolBar


-(instancetype)initWithFrame:(CGRect)frame{
    if (self = [super initWithFrame:frame]) {
        
        CGFloat btnw = self.width/3;
        
        for (NSInteger i = 0; i < 3; i++) {
            UIButton *btn = [UIButton buttonWithType:UIButtonTypeCustom];
            [btn setTitleColor:[UIColor lightGrayColor] forState:UIControlStateNormal];
            [btn setTitle:@"39479" forState:UIControlStateNormal];
            if (i == 0) {
                [btn setImage:[UIImage imageNamed:@"icon_zan"] forState:UIControlStateNormal];
            }else if (i == 1){
                [btn setImage:[UIImage imageNamed:@"icon_look"] forState:UIControlStateNormal];
            }else{
                [btn setImage:[UIImage imageNamed:@"icon_feed"] forState:UIControlStateNormal];
            }
            [btn addTarget:self action:@selector(btnClick:) forControlEvents:UIControlEventTouchUpInside];
            btn.imageEdgeInsets = UIEdgeInsetsMake(0, -AD(5), 0, 0);
            btn.frame = CGRectMake(i * btnw, 0, btnw, self.height);
            [self addSubview:btn];
            
        }
        
        [self addSubview:self.lineView1];
        [self addSubview:self.lineView2];
        [self addSubview:self.lineView3];
        
    }
    return self;
}

- (void)btnClick:(UIButton *)sender{
    NSLog(@"%@", sender.titleLabel.text);
}

-(UIView *)lineView1{
    if (!_lineView1) {
        _lineView1 = [[UIView alloc] initWithFrame:CGRectMake(0, 0, self.width, AD(0.5))];
        _lineView1.backgroundColor = [[UIColor lightGrayColor] colorWithAlphaComponent:0.3];
    }
    return _lineView1;
}

-(UIView *)lineView2{
    if (!_lineView2) {
        _lineView2 = [[UIView alloc] initWithFrame:CGRectMake(self.width/3, AD(5), AD(0.5), self.height-AD(10))];
        _lineView2.backgroundColor = [[UIColor lightGrayColor] colorWithAlphaComponent:0.3];
    }
    return _lineView2;
}

-(UIView *)lineView3{
    if (!_lineView3) {
        _lineView3 = [[UIView alloc] initWithFrame:CGRectMake((self.width/3)*2, AD(5), _lineView2.width, _lineView2.height)];
        _lineView3.backgroundColor = [[UIColor lightGrayColor] colorWithAlphaComponent:0.3];
    }
    return _lineView3;
}

@end
